/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.hyjiacan.deadqq.server.window;

import org.hyjiacan.deadqq.common.entity.User;
import org.hyjiacan.deadqq.common.util.WindowUtil;
import org.hyjiacan.deadqq.server.dao.UserDAO;


/**
 *
 * @author hyjiacan
 */
public class ServerWindow extends javax.swing.JFrame implements Runnable {

    private static ServerWindow instance;

    /**
     * Creates new form ServerWindow
     */
    private ServerWindow() {
    }

    @Override
    public void run() {
        initComponents();
        WindowUtil.center(instance);

        this.setVisible(true);
        new Thread() {

            @Override
            public void run() {
                loadData();
            }
        }.start();
    }
/**
 * 载入数据库中的用户数据，并显示到列表中
 */
    private void loadData() {
        UserDAO ud = new UserDAO();
        User u = ud.queryById(1);
        
    }

    public static ServerWindow getInstance() {
        if (instance == null) {
            instance = new ServerWindow();
        }
        return instance;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed"
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        FirstPage = new javax.swing.JButton();
        PrePage = new javax.swing.JButton();
        NextPage = new javax.swing.JButton();
        LastPage = new javax.swing.JButton();
        JumpToPage = new javax.swing.JTextField();
        JumpTo = new javax.swing.JButton();
        PageInfo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(640, 480));
        setResizable(false);

        FirstPage.setText("第一页");

        PrePage.setText("上一页");
        PrePage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrePageActionPerformed(evt);
            }
        });

        NextPage.setText("下一页");

        LastPage.setText("最后一页");

        JumpToPage.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        JumpToPage.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));

        JumpTo.setText("转到");

        PageInfo.setText("1/3122");
        PageInfo.setToolTipText("");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(92, 92, 92)
                .addComponent(FirstPage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PrePage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(NextPage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LastPage)
                .addGap(45, 45, 45)
                .addComponent(JumpToPage, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JumpTo)
                .addGap(18, 18, 18)
                .addComponent(PageInfo)
                .addContainerGap(55, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(455, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FirstPage)
                    .addComponent(PrePage)
                    .addComponent(NextPage)
                    .addComponent(LastPage)
                    .addComponent(JumpToPage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JumpTo)
                    .addComponent(PageInfo))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void PrePageActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_PrePageActionPerformed
        // TODO add your handling code here:
    }// GEN-LAST:event_PrePageActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton FirstPage;
    private javax.swing.JButton JumpTo;
    private javax.swing.JTextField JumpToPage;
    private javax.swing.JButton LastPage;
    private javax.swing.JButton NextPage;
    private javax.swing.JLabel PageInfo;
    private javax.swing.JButton PrePage;
    // End of variables declaration//GEN-END:variables
}
